package com.eco.fanliapp.controller.exapi;


import com.eco.fanliapp.common.response.ServerResponse;
import com.eco.fanliapp.service.*;
import com.eco.fanliapp.taobao.TklController;
import com.eco.fanliapp.utils.StringUtils;
import com.taobao.api.response.TbkTpwdCreateResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/web/Tkl")
public class TklOpenController {

    private static final Logger log = LoggerFactory.getLogger(TklOpenController.class);

    @Autowired
    private TklController tklController;


    @GetMapping("/getTkl")
    @ResponseBody
    public ServerResponse<String> getTkl(String itemTitle, String itemPic, String couponUrl) {
        log.info("商品标题{}" + itemTitle + ",图片{}" + itemPic + ",优惠卷链接{}" + couponUrl);
        TbkTpwdCreateResponse rsp = (TbkTpwdCreateResponse) tklController.tklPost(itemTitle, itemPic, couponUrl);
        if (rsp != null && rsp.getData() != null) {
            return ServerResponse.createBySuccess("数据获取成功", rsp.getData().getModel());
        }
        return ServerResponse.createBySuccessCodeMessage(201, "没有数据");
    }

}
